package com.yst.web.controller.system;

import com.yst.common.annotation.DataScope;
import com.yst.common.core.domain.AjaxResult;
import com.yst.common.core.domain.R;
import com.yst.system.domain.IndexQueryParams;
import com.yst.system.service.IBasItemService;
import com.yst.system.service.ISellOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ISellOrderService orderService;


    @Autowired
    private IBasItemService iBasItmeService;

    /**
     *按日期查看每天每个门店的销售额
     * @param indexQueryParams
     * @return
     */
    @GetMapping("/saleByDay")
    @DataScope(deptAlias = "d")
    public AjaxResult saleByDay(IndexQueryParams indexQueryParams){
        return orderService.saleByDay(indexQueryParams);
    }

    /**
     *根据产品类型、日期区间查看产品型号销售情况
     * @param indexQueryParams
     * @return
     */
    @GetMapping("/saleByItemType")
    @DataScope(deptAlias = "a")
    public AjaxResult saleByItemType(IndexQueryParams indexQueryParams){
        return orderService.saleByItemType(indexQueryParams);
    }

    /**
     * 根据时间区间查看销售人员销售额
     * @param indexQueryParams
     * @return
     */
    @GetMapping("/saleBySalesman")
    @DataScope(deptAlias = "a")
    public AjaxResult saleBySalesman(IndexQueryParams indexQueryParams){
        return orderService.saleBySalesman(indexQueryParams);
    }

    /**
     * 根据产品统计销量与销售额
     * @param indexQueryParams
     * @return
     */
    @GetMapping("/saleByItem")
    @DataScope(deptAlias = "b")
    public AjaxResult saleByItem(IndexQueryParams indexQueryParams){
        return iBasItmeService.saleByItem(indexQueryParams);
    }

}
